﻿@using OnlineStore.Models
@model IEnumerable<OnlineStore.Models.Order>

@{
}

<h2>所有订单</h2>

<table class="table">
    <tr>
        <th>订单号</th>
        <th>买家</th>
        <th>完成时间</th>
        <th>订单状态</th>
        <th>操作</th>
    </tr>
    @foreach (var item in Model)
    {
        <tr>
            <td>@item.Uid</td>
            <td>@item.User.Name</td>
            <td>@item.DoneTime</td>
            @switch (item.State)
            {
                case OrderState.WaitToDeal:
                    <td><span class="text-primary">待发货</span></td>
                    break;
                case OrderState.Shipped:
                    <td><span class="text-muted">已发货</span></td>
                    break;
                case OrderState.Completed:
                    <td><span class="text-primary">已完成</span></td>
                    break;
                default:
                    throw new ArgumentOutOfRangeException();
            }
            <td>
                <a asp-action="Details" asp-route-uid="@item.Uid" class="btn btn-outline-primary">详情</a>
                @if (item.State == OrderState.WaitToDeal)
                {
                    <a asp-action="Send" asp-route-uid="@item.Uid" class="btn btn-outline-danger">处理订单</a>   
                }
            </td>
        </tr>
    }
</table>